/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function initAutosReasignablesGrid(){
    $("#autosreasignables_grid").jqGrid({
        url:'getAutosResaignables.do',
        datatype: "json",
        width:900,
 colNames:['Marca','Descripción','Modelo','Precio de Factura','Fecha de factura'],
        colModel:[
        {
            name:'marca',
            index:'marca',
            sortable: true, 
             editable: true,       
            editoptions:{readonly: true},        
            width:55
        },

        {
            name:'descipcioncorta',
            index:'descipcioncorta', 
             editoptions:{readonly: true},
            sortable: true,
            editable: true,            
            width:90
        },

        {
            name:'modelo',
            index:'modelo',
            sortable: true, 
             editrules: { required: true},
             editable: true,    
            width:100
        },

        {
            name:'preciofactura',
            index:'preciofactura', 
            sortable: true,
             editable: true,   
              editrules: { required: true},
            width:100, 
            align:"right"
        },
        
        {
            name:'fechafactura',
            index:'fechafactura',
            sortable:true, 
             editable: true, 
              editrules: { required: true},
            width:100, 
            align:"rigth"
        }/*,
                {
            name:'actions',
            index:'actions',
            sortable: false, 
            width:80, 
            
            align:"center"
        }*/ 		
  
        ],
        ondblClickRow: function(precio, amount, total){
            //alert(precio)
               /* $( "#dialog-confirm" ).dialog({  
                     modal: true,
                     resizable: true,               
                      height: 600,
                      width: 1000,
                      position: 'center',
                      zIndex: 10000 

                   });
                   dwrService.getAutoDetail(function(data)
                        {
                               dwr.util.setValue('detail', data,{
                                    escapeHtml:false
                               });
                   });*/
            
              div = document.getElementById('detail');
              div.style.display = "";
              dwrService.detailAutoReasignable(function(data)
                        {
                               dwr.util.setValue('detail', data,{
                                    escapeHtml:false
                                    
                               });
                   });
              div = document.getElementById('fomatodecaptura');
              div.style.display = "";      
                   
        },
        rowNum:10,
        rowList:[10,20,30],
        pager: '#autos_pager',
        sortname: 'precio',
        viewrecords: true,
        sortable: true,
        sortorder: "desc",
        multiselect: false,
        caption:"",
        loadonce : false,
        rowTotal: 'total',
        records:'records',
        jsonReader: {
            repeatitems: false,
            id: "precio"
        }, 
        gridComplete: function(){
 	  
            var ids =$("#autosreasignables_grid").jqGrid('getDataIDs');
	  
            for(var i=0;i < ids.length;i++){
                var precio_ = ids[i]; 
                
                icon2= " <img src='img/infoicon.png'alt='Ver auto' title='Aceptar' height='16' onclick=\"detail('"+precio_+"',1);\" width='16'  />";
                //icon3= " <img src='img/icon2.png' alt='Rechazar' title='Rechazar' height='18' onclick=\"changeStatusSolicitudAcceso('"+precio_+"',2);\" width='18'  />";
                $("#autosnuevos_grid").jqGrid('setRowData',ids[i],{
                    actions:icon2//+icon3
                }); 
            }
 
        }
    });
    $("#autosreasignables_grid").jqGrid('navButtonAdd','#autos_pager',{
        edit:true,
        add:true,
        view :true,
        del:true,
    },{},{},{closeAfterEdit:true},{} );

}

var myDelOptions = {
            
    onclickSubmit: function(rp_ge, rowid) {
                      
       // alert("The row with rowid="+rowid+" will be deleted");
        
        $("#autosreasignables_grid").delRowData(rowid);
                        

        //                jQuery("#grid_id").jqGrid('saveRow',rowid, false);

        return true;
    },
    url:'solicitud.do?action=del'
//,  processing:true
};

/*
function getTipoAutos(){
    var ptipoauto = ctipoauto.value;
    div = document.getElementById('fomatodecaptura');
         div.style.display='none';
         
    div = document.getElementById('detail');
    div.style.display = 'none';
    
    if(ctipoauto.checked){
        //alert("checket")
     $("#autosnuevos_grid").setGridParam({
                   url:'getAutosNuevos.do?tipoauto='+ptipoauto
        }).trigger("reloadGrid");
    }else{
         //alert("UN-checket")
         $("#autosnuevos_grid").setGridParam({
                   url:'getAutosNuevos.do?tipoauto=0'
        }).trigger("reloadGrid");
    }
        
}*/
 
